<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- 
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License. 
-->
<html>
<head>
    <link type="text/css" rel="stylesheet" href="https://struts.apache.org/css/default.css">
    <style type="text/css">
        .dp-highlighter {
            width:95% !important;
        }
    </style>
    <style type="text/css">
        .footer {
            background-image:      url('https://cwiki.apache.org/confluence/images/border/border_bottom.gif');
            background-repeat:     repeat-x;
            background-position:   left top;
            padding-top:           4px;
            color:                 #666;
        }
    </style>
    <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' />
    <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' />
    <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script>
    <script type="text/javascript">
        SyntaxHighlighter.defaults['toolbar'] = false;
        SyntaxHighlighter.all();
    </script>
    <script type="text/javascript" language="javascript">
        var hide = null;
        var show = null;
        var children = null;

        function init() {
            /* Search form initialization */
            var form = document.forms['search'];
            if (form != null) {
                form.elements['domains'].value = location.hostname;
                form.elements['sitesearch'].value = location.hostname;
            }

            /* Children initialization */
            hide = document.getElementById('hide');
            show = document.getElementById('show');
            children = document.all != null ?
                    document.all['children'] :
                    document.getElementById('children');
            if (children != null) {
                children.style.display = 'none';
                show.style.display = 'inline';
                hide.style.display = 'none';
            }
        }

        function showChildren() {
            children.style.display = 'block';
            show.style.display = 'none';
            hide.style.display = 'inline';
        }

        function hideChildren() {
            children.style.display = 'none';
            show.style.display = 'inline';
            hide.style.display = 'none';
        }
    </script>
    <title>WebSphere</title>
</head>
<body onload="init()">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr class="topBar">
        <td align="left" valign="middle" class="topBarDiv" align="left" nowrap>
            &nbsp;<a href="home.html">Home</a>&nbsp;&gt;&nbsp;<a href="guides.html">Guides</a>&nbsp;&gt;&nbsp;<a href="core-developers-guide.html">Core Developers Guide</a>&nbsp;&gt;&nbsp;<a href="application-servers.html">Application Servers</a>&nbsp;&gt;&nbsp;<a href="websphere.html">WebSphere</a>
        </td>
        <td align="right" valign="middle" nowrap>
            <form name="search" action="https://www.google.com/search" method="get">
                <input type="hidden" name="ie" value="UTF-8" />
                <input type="hidden" name="oe" value="UTF-8" />
                <input type="hidden" name="domains" value="" />
                <input type="hidden" name="sitesearch" value="" />
                <input type="text" name="q" maxlength="255" value="" />
                <input type="submit" name="btnG" value="Google Search" />
            </form>
        </td>
    </tr>
</table>

<div id="PageContent">
    <div class="pageheader" style="padding: 6px 0px 0px 0px;">
        <!-- We'll enable this once we figure out how to access (and save) the logo resource -->
        <!--img src="/wiki/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"-->
        <div style="margin: 0px 10px 0px 10px" class="smalltext">Apache Struts 2 Documentation</div>
        <div style="margin: 0px 10px 8px 10px"  class="pagetitle">WebSphere</div>

        <div class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;">
            <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=13934">
                <img src="https://cwiki.apache.org/confluence/images/icons/notep_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Edit Page"></a>
            <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=13934">Edit Page</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">
                <img src="https://cwiki.apache.org/confluence/images/icons/browse_space.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Browse Space"></a>
            <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">Browse Space</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=13934">
                <img src="https://cwiki.apache.org/confluence/images/icons/add_page_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Add Page"></a>
            <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=13934">Add Page</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=13934">
                <img src="https://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Add News"></a>
            <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=13934">Add News</a>
        </div>
    </div>

    <div class="pagecontent">
        <div class="wiki-content">
            <div id="ConfluenceContent"><h2 id="WebSphere-WebSphere5.1">WebSphere 5.1</h2>

<p><img class="emoticon emoticon-tick" src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/emoticons/check.png" data-emoticon-name="tick" alt="(tick)"> <a shape="rect" class="external-link" href="http://forums.opensymphony.com/thread.jspa?threadID=26068" rel="nofollow">Be sure to install WebSphere's Fix Pack 1</a>.</p>

<h2 id="WebSphere-WebSphere6">WebSphere 6</h2>

<p>See forum thread: <a shape="rect" class="external-link" href="http://forums.opensymphony.com/message.jspa?messageID=119574#119574" rel="nofollow">http://forums.opensymphony.com/message.jspa?messageID=119574#119574</a></p>

<blockquote>
<p>It looks like there is a bug in WebSphere App Server related to which classloader is used at the time that Struts2 is loading the properties files, (all properties files, not just struts.properties and default.properties). The bug may have been fixed in WAS 6.0.2.9, (check out this link for details <a shape="rect" class="external-link" href="http://www-1.ibm.com/support/docview.wss?uid=swg27006876" rel="nofollow">http://www-1.ibm.com/support/docview.wss?uid=swg27006876</a>).</p>

<p>If you just want to confirm the issue, or you need just a temporary fix, try this:</p>

<p>1) jar up all properties files for your project, (including default.properties in its full path), and put these into the WS common applications lib directory at the same level as the "profiles" directory.<br clear="none">
2) Run the application - everything should work</p>

<p>This solution is strictly temporary, as all struts2 apps in this instance of WAS would have to use the same properties files. A better solution:</p>

<p>1) add a servlet that initializes the Struts Dispatcher with the servlet context:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
import org.apache.struts2.dispatcher.Dispatcher;
 
public class LaunchServlet extends HttpServlet implements Servlet {
 
	public LaunchServlet() {
		super();
	}
 
	public void init(ServletConfig arg0) throws ServletException {
		
		// this works around a bug in the websphere classloader.
		super.init(arg0);
		Dispatcher d = new Dispatcher(getServletContext(), new HashMap&lt;String, String&gt;());	
		
	}
 
}
</pre>
</div></div>
<p>2) launch it at start-up (web.xml):</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
    &lt;servlet&gt;
      &lt;servlet-name&gt;dummyaction&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.xxx.yyyyyy.service.LaunchServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
</pre>
</div></div>
<p>3) Run application and everything should work. </p></blockquote>

<h2 id="WebSphere-WebSphere6.5">WebSphere 6.5</h2>

<p>To make struts2 work in Websphere, one has to set Websphere specific properties, you may want to add that to the wiki:</p>

<p>The properties are:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror = true
com.ibm.ws.webcontainer.invokefilterscompatibility = true
</pre>
</div></div>

<p>At least that is necessary when using StrutsPrepareAndExecuteFilter.</p>

<p>In Websphre admin console one has to add those properties here:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>Servers &gt; Application servers &gt; {server name} &gt; Web container &gt; Custom Properties
</pre>
</div></div>

<p>A wsadmin jython script to set those properties could look like this:</p>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">

def findObjectName(objectId):
        index = objectId.find('(')
        return objectId[0 : index]

node = AdminNodeManagement.listNodes()[0]
server = AdminConfig.list('Server')

nodeName = findObjectName(node)
serverName = findObjectName(server)

webContainer = AdminConfig.list('WebContainer', node)
webContainerDetails = AdminConfig.show(webContainer)

if webContainerDetails.find("com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror") == -1:
        print "creating prop: com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror"
        AdminServerManagement.configureCustomProperty(nodeName, serverName, "WebContainer","com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror", "true")
if webContainerDetails.find("com.ibm.ws.webcontainer.invokefilterscompatibility") == -1:
        print "creating prop: com.ibm.ws.webcontainer.invokefilterscompatibility"
        AdminServerManagement.configureCustomProperty(nodeName, serverName, "WebContainer", "com.ibm.ws.webcontainer.invokefilterscompatibility", "true")
</pre>
</div></div>

<p>Thanks to Christoph Nenning (christoph dot nenning at lex-com at net)</p>

<h2 id="WebSphere-JSESSIONIDhandling">JSESSIONID handling</h2>

<p>IBM WebSphere Application Server uses the JSESSIONID information to keep track of the client session. If you have an application where the application client must navigate across multiple WebSphere Application Server nodes residing in same domain, then the JSESSIONID information may be over-written on the client because multiple JSESSIONID cookies received with the same name and path.</p>

<p>When persistence is disabled and if the JSESSIONID in the incoming request is not found in the current session manager, then the session manager will generate a new sessionId and create a session object, instead of using the sessionId in the incoming request.</p>

<p>To resolve this issue, configure WebSphere Application Server to reuse the sessionId present in the incoming request.</p>

<p>For All versions:</p>
<ol><li>Open the administrative console.</li><li>Select Servers &gt; Application Servers &gt; Server_Name &gt; Server Infrastructure &gt; Java and Process Management &gt; Process Definition &gt; Java Virtual Machine &gt; Custom Properties &gt; New</li><li>Add a new Custom Property for the JVM to reuse the sessionId:
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>System Property Name: HttpSessionIdReuse
System Property Value: true
</pre>
</div></div></li><li>Save your changes and restart the Application Server.</li></ol>


<p>If the application client does not navigate across multiple WebSphere Application Server nodes residing in the same domain but there are multiple WARs with different context roots, following is the step that needs to be followed for session to be maintained in one web application:</p>
<ol><li>Open the administrative console.</li><li>Select Application servers &gt; Server_Name &gt; Session management &gt; Cookies</li><li>In "Cookie Path", specify the context root of web application in which session needs to be maintained. This will ensure that cookies are sent only to /&lt;&lt;context_root&gt;&gt; URL and prevent overriding of JSSESSIONID cookie which results in new session creation by WAS.</li><li>Save your changes and restart the Application Server.</li></ol>


<p>Thanks to Vineet Kanwal from IBM!</p></div>
        </div>

        
    </div>
</div>
<div class="footer">
    Generated by CXF SiteExporter
</div>
</body>
</html>
